home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-03-26 | 24.1 KB | 865 lines | [TEXT/R*ch] |
- % Copyright (C) 1994, 1995, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
- %
- % This file is part of Aladdin Ghostscript.
- %
- % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
- % or distributor accepts any responsibility for the consequences of using it,
- % or for whether it serves any particular purpose or works at all, unless he
- % or she says so in writing. Refer to the Aladdin Ghostscript Free Public
- % License (the "License") for full details.
- %
- % Every copy of Aladdin Ghostscript must include a copy of the License,
- % normally in a plain ASCII text file named PUBLIC. The License grants you
- % the right to copy, modify and redistribute Aladdin Ghostscript, but only
- % under certain conditions described in the License. Among other things, the
- % License requires that the copyright notice and this notice be preserved on
- % all copies.
-
- % $Id: pdf_draw.ps,v 1.1 2000/03/09 08:40:40 lpd Exp $
- % pdf_draw.ps
- % PDF drawing operations (graphics, text, and images).
-
- /.setlanguagelevel where { pop 2 .setlanguagelevel } if
- .currentglobal true .setglobal
- /pdfdict where { pop } { /pdfdict 100 dict def } ifelse
- GS_PDF_ProcSet begin
- pdfdict begin
-
- % For simplicity, we use a single interpretation dictionary for all
- % PDF graphics operations, even though this is too liberal.
- /drawopdict 100 dict def
-
- % ================================ Graphics ================================ %
-
- % ---------------- Functions ---------------- %
-
- /fnrdict mark
- 0 { .resolvefn0 }
- 2 { }
- 3 { .resolvefn3 }
- 4 { .resolvefn4 }
- .dicttomark readonly def
-
- /.pdfbuildfunction {
- DEBUG { (%Function: ) print dup === flush } if
- .buildfunction
- } bdef
-
- /.resolvefn0 {
- % Don't lose our place in PDFfile.
- PDFfile fileposition exch
- dup true resolvestream
- % The stream isn't positionable, so read all the data now.
- % Stack: filepos fndict stream
- 1 index /Range oget length 2 idiv 2 index /BitsPerSample oget mul
- 2 index /Size oget { mul } forall
- 7 add 8 idiv string
- 1 index exch readstring pop exch closefile
- % Stack: filepos fndict data
- exch dup length 1 add dict .copydict
- dup /DataSource 4 -1 roll put
- .pdfbuildfunction
- exch PDFfile exch setfileposition
- } bdef
-
- /.resolvefn3 {
- dup length dict .copydict
- dup /Functions 2 copy oget mark exch dup {
- oforce resolvefunction
- } forall
- counttomark -1 roll astore exch pop put
- } bdef
-
- /tfopdict mark
- /true /.true load
- /false /.false load
- .dicttomark readonly def
- /.resolvefn4 {
- PDFfile fileposition exch
- dup true resolvestream
- % Stack: filepos fndict stream
- 1 index /Length oget string readstring pop
- exch dup length dict copy dup /Function undef
- exch token not {
- () /rangecheck cvx signalerror
- } if
- exch token {
- /rangecheck cvx signalerror
- } if
- % Use .bind to avoid idiom recognition.
- % Use tfopdict to bind true and false.
- //tfopdict begin .bind end
- 1 index /Function 3 -1 roll put
- .pdfbuildfunction
- exch PDFfile exch setfileposition
- } bdef
- currentdict /tfopdict undef
-
- /resolvefunction { % <fndict> resolvefunction <function>
- dup /FunctionType oget //fnrdict exch get exec
- } bdef
-
- /resolveidfunction {
- dup /Identity eq { pop { } } { resolvefunction } ifelse
- } bdef
-
- /resolvedefaultfunction { % <fndict> <default> resolved'f'n <function>
- 1 index /Default eq { exch pop } { pop resolveidfunction } ifelse
- } bdef
-
- % ---------------- Shadings ---------------- %
-
- /shrdict mark
- /ColorSpace {
- resolvecolorspace
- }
- /Function {
- dup type /dicttype eq {
- resolvefunction
- } {
- [ exch { resolvefunction } forall ]
- } ifelse
- }
- .dicttomark readonly def
-
- /resolveshading { % <shname> resolveshading <shading>
- Page /Shading rget {
- mark exch {
- oforce //shrdict 2 index .knownget { exec } if
- } forall .dicttomark
- dup /ShadingType get 4 ge {
- dup dup true resolvestream /DataSource exch put
- } if
- } {
- null
- } ifelse
- } bdef
-
- % ---------------- Halftones ---------------- %
-
- /spotfunctions mark
- /Round {
- abs exch abs 2 copy add 1 le {
- dup mul exch dup mul add 1 exch sub
- } {
- 1 sub dup mul exch 1 sub dup mul add 1 sub
- } ifelse
- }
- /Diamond {
- abs exch abs 2 copy add .75 le {
- dup mul exch dup mul add 1 exch sub
- } {
- 2 copy add 1.23 le {
- .85 mul add 1 exch sub
- } {
- 1 sub dup mul exch 1 sub dup mul add 1 sub
- } ifelse
- } ifelse
- }
- /Ellipse {
- abs exch abs 2 copy 3 mul exch 4 mul add 3 sub dup 0 lt {
- pop dup mul exch .75 div dup mul add 4 div 1 exch sub
- } {
- dup 1 gt {
- pop 1 exch sub dup mul exch 1 exch sub
- .75 div dup mul add 4 div 1 sub
- } {
- .5 exch sub exch pop exch pop
- } ifelse
- } ifelse
- }
- /EllipseA { dup mul .9 mul exch dup mul add 1 exch sub }
- /InvertedEllipseA { dup mul .9 mul exch dup mul add 1 sub }
- /EllipseB { dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub }
- /EllipseC { dup mul .9 mul exch dup mul add 1 exch sub }
- /InvertedEllipseC { dup mul .9 mul exch dup mul add 1 sub }
- /Line { exch pop abs neg }
- /LineX { pop }
- /LineY { exch pop }
- /Square { abs exch abs 2 copy lt { exch } if pop neg }
- /Cross { abs exch abs 2 copy gt { exch } if pop neg }
- /Rhomboid { abs exch abs 0.9 mul add 2 div }
- /DoubleDot { 2 {360 mul sin 2 div exch } repeat add }
- /InvertedDoubleDot { 2 {360 mul sin 2 div exch } repeat add neg }
- /SimpleDot { dup mul exch dup mul add 1 exch sub }
- /InvertedSimpleDot { dup mul exch dup mul add 1 sub }
- /CosineDot { 180 mul cos exch 180 mul cos add 2 div }
- /Double { exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add }
- /InvertedDouble {
- exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add neg
- }
- .dicttomark readonly def
-
- /htrdict mark
- 1 { .resolveht1 }
- 5 { .resolveht5 }
- % We don't support types 6, 10, or 16 yet.
- .dicttomark readonly def
-
- /.resolveht1 {
- mark exch {
- oforce
- 1 index /SpotFunction eq {
- dup type /nametype eq
- { //spotfunctions exch get } { resolvefunction }
- ifelse
- } {
- 1 index /TransferFunction eq {
- resolveidfunction
- } if
- } ifelse
- } forall .dicttomark
- } bdef
-
- /.resolveht5 {
- mark exch {
- oforce dup type /dicttype eq { resolvehalftone } if
- } forall .dicttomark
- } bdef
-
- /resolvehalftone { % <dict> resolvehalftone <halftone>
- dup /HalftoneType get //htrdict exch get exec
- } bdef
-
- % ---------------- Graphics state management ---------------- %
-
- /cmmatrix matrix def
- drawopdict begin
- % Graphics state stack
- /q { q } def
- /Q { Q } def
- % Graphics state setting
- /cm { //cmmatrix astore concat } def
- /i /setflat load def
- /J /setlinecap load def
- /d /setdash load def
- /j /setlinejoin load def
- /w /setlinewidth load def
- /M /setmiterlimit load def
- /gs { gs } def
- end
-
- % Each entry in this dictionary is
- % <gsres> <value> -proc- <gsres>
- /gsbg { /BGDefault load resolvedefaultfunction setblackgeneration } bdef
- /gsucr { /UCRDefault load resolvedefaultfunction setundercolorremoval } bdef
- %****** DOESN'T IMPLEMENT THE ARRAY (colortransfer) CASE YET ******
- /gstr { /TRDefault load resolvedefaultfunction settransfer } bdef
- /gsparamdict mark
- /SA { setstrokeadjust }
- /op {
- %****** STROKE OVERPRINT, NOT IMPLEMENTED YET ******
- pop
- }
- /OP { setoverprint }
- /OPM {
- %****** OVERPRINT MODE, NOT IMPLEMENTED YET ******
- pop
- }
- % The PDF 1.3 specification says that the name /Default is only
- % recognized for {BG,UCR,TR}2. However, PDF 1.3 files produced
- % by Adobe Acrobat Distiller 4.0 for Windows use the name /Default
- % with the older keys, so we have to implement this.
- /BG { 1 index /BG2 known { pop } { gsbg } ifelse }
- /BG2 { gsbg }
- /UCR { 1 index /UCR2 known { pop } { gsucr } ifelse }
- /UCR2 { gsucr }
- /TR { 1 index /TR2 known { pop } { gstr } ifelse }
- /TR2 { gstr }
- /HT {
- dup /Default eq {
- pop .setdefaultscreen
- } {
- %****** DOESN'T IMPLEMENT THE STREAM CASE YET ******
- resolvehalftone sethalftone
- } ifelse
- }
- % HTP may be present even if this isn't a DPS interpreter.
- /HTP {
- /sethalftonephase where { pop aload pop sethalftonephase } { pop } ifelse
- }
- % SM may be present even if this is only a Level 2 interpreter.
- /SM {
- /setsmoothness where { pop setsmoothness } { pop } ifelse
- }
- /Font { aload pop Tf }
- /LW { setlinewidth }
- /LC { setlinecap }
- /LJ { setlinejoin }
- /ML { setmiterlimit }
- /D { aload pop setdash }
- /FL { setflat }
- /RI { ri }
- .dicttomark readonly def
- /gs { % <gsres> gs -
- Page /ExtGState rget {
- % We keep the dictionary on the stack during the forall so that
- % keys that interact with each other have access to it.
- dup {
- oforce exch gsparamdict exch .knownget { exec } { pop } ifelse
- } forall pop
- } if
- } bdef
-
- % ---------------- Color setting ---------------- %
-
- /01_1 [0 1] readonly def
- /01_3 [0 1 0 1 0 1] readonly def
- /01_4 [0 1 0 1 0 1 0 1] readonly def
-
- % The keys here are resolved (PostScript, not PDF) color space names.
- /csncompdict mark
- /DeviceGray { pop 1 }
- /DeviceRGB { pop 3 }
- /DeviceCMYK { pop 4 }
- /CIEBasedA { pop 1 }
- /CIEBasedABC { pop 3 }
- /Separation { pop 1 }
- /DeviceN { 2 oget length }
- .dicttomark readonly def
-
- % Perhaps some of the values in the following need to be modified
- % depending on the WhitePoint value....
- /cslabinit mark
- /DecodeABC [{16 add 116 div} bind {500 div} bind {200 div} bind]
- /MatrixABC [1 1 1 1 0 0 0 0 -1]
- /DecodeLMN [
- {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse
- 0.9505 mul} bind
- {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse
- } bind
- {dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse
- 1.0890 mul} bind
- ]
- .dicttomark readonly def
-
- /csrdict mark
- /DeviceGray {
- /DefaultGray Page /ColorSpace rget { exch pop resolvecolorspace } if
- }
- /DeviceRGB {
- /DefaultRGB Page /ColorSpace rget { exch pop resolvecolorspace } if
- }
- /DeviceCMYK { }
- /CalGray {
- 1 oget 6 dict begin
- dup /Gamma knownoget {
- /exp load 2 packedarray cvx /DecodeA exch def
- } if
- dup /BlackPoint knownoget { /BlackPoint exch def } if
- dup /WhitePoint knownoget { /WhitePoint exch def } if
- pop [ /CIEBasedA currentdict end ]
- }
- /CalRGB {
- 1 oget 6 dict begin
- dup /Gamma knownoget {
- [ exch { /exp load 2 packedarray cvx } forall
- ] /DecodeABC exch def
- } if
- dup /Matrix knownoget { /MatrixABC exch def } if
- dup /BlackPoint knownoget { /BlackPoint exch def } if
- dup /WhitePoint knownoget { /WhitePoint exch def } if
- pop [ /CIEBasedABC currentdict end ]
- }
- /CalCMYK {
- pop /DeviceCMYK % not defined by Adobe
- }
- /Lab {
- 1 oget 6 dict begin
- dup /Range knownoget not { [-100 100 -100 100] } if
- [0 100 null null null null] dup 2 4 -1 roll putinterval
- /RangeABC exch def
- //cslabinit { def } forall
- dup /BlackPoint knownoget { /BlackPoint exch def } if
- dup /WhitePoint knownoget { /WhitePoint exch def } if
- pop [ /CIEBasedABC currentdict end ]
- }
- /ICCBased {
- % Since the PostScript interpreter doesn't support these yet,
- % always substitute an alternate space.
- 1 oget dup /Alternate knownoget {
- exch pop
- } {
- /N get { null /DeviceGray null /DeviceRGB /DeviceCMYK } exch get
- } ifelse resolvecolorspace
- }
- /Separation {
- aload pop exch oforce resolvecolorspace exch oforce resolvefunction
- 4 array astore
- }
- /DeviceN {
- aload pop 3 -1 roll oforce
- 3 -1 roll oforce resolvecolorspace
- 3 -1 roll oforce resolvefunction
- 4 array astore
- }
- /Indexed {
- aload pop 3 -1 roll oforce resolvecolorspace
- % If the underlying space is a Lab space, we must scale
- % the output of the lookup table as part of DecodeABC.
- dup dup type /arraytype eq { 0 get } if /CIEBasedABC eq {
- dup 1 get /DecodeLMN known {
- 1 get dup length dict copy
- begin /DecodeABC [ 0 2 4 {
- RangeABC 1 index 1 add get RangeABC 2 index get sub /mul load
- RangeABC 3 index get /add load
- DecodeABC 6 -1 roll 2 idiv get [ 6 1 roll aload pop ] cvx
- } for ] def
- /RangeABC //01_3 def
- currentdict end /CIEBasedABC exch 2 array astore
- } if
- } if
- 3 1 roll
- oforce dup type /stringtype ne {
- % The color lookup table is a stream.
- % Get its contents. Don't lose our place in PDFfile.
- % Stack: /Indexed basespace hival lookup
- PDFfile fileposition 5 1 roll true resolvestream
- % Stack: filepos /Indexed basespace hival lookupstream
- 1 index 1 add
- % Stack: filepos /Indexed basespace hival lookupstream len
- 3 index
- dup dup type /arraytype eq { 0 get } if
- //csncompdict exch get exec mul
- string readstring pop
- % Stack: filepos /Indexed basespace hival table
- 5 -1 roll PDFfile exch setfileposition
- }
- if 4 array astore
- }
- /Pattern {
- dup type /nametype ne {
- dup length 1 gt {
- 1 oget resolvecolorspace
- /Pattern exch 2 array astore
- } if
- } if
- }
- .dicttomark readonly def
-
- /cssubst { % <csname> cssubst <cspace'> true
- % <csname> cssubst false
- dup resolvecolorspace
- dup 1 index ne { exch pop true } { pop pop false } ifelse
- } bdef
-
- /csnames mark
- /DeviceGray dup /DeviceRGB dup /DeviceCMYK dup /Pattern dup
- .dicttomark readonly def
- /csresolve { % <csresourcename> csresolve <cspace>
- dup Page /ColorSpace rget {
- exch pop resolvecolorspace
- } {
- //csnames 1 index known not { /undefined cvx signalerror } if
- } ifelse
- } bdef
- /resolvecolorspace { % <cspace> resolvecolorspace <cspace'>
- dup dup type /arraytype eq { 0 get } if
- //csrdict exch .knownget {
- exec dup type /nametype ne { dup length 1 eq { 0 get } if } if
- } {
- csresolve
- } ifelse
- } bdef
-
- /scresolve { % <c0> ... scresolve <multi>
- % We can't really make sc[n] and SC[N] work, because
- % the color space information isn't available at
- % conversion time; so we hack it by assuming that
- % all the operands on the stack are used, and that
- % if the top operand is a name, it's a Pattern resource.
- dup type /nametype eq
- { Page /Pattern rget { resolvepattern } { null } ifelse }
- if
- dup type /dicttype eq {
- % Check the PaintType
- dup /PaintType get 2 eq
- } {
- .pdfcount 1 gt
- } ifelse
- } bdef
-
- /.pdfpaintproc { % <patdict> <resdict> .pdfpaintproc -
- DEBUG { (%Begin PaintProc) = flush } if
- % For uncolored patterns, we have to unbind the current
- % color and color space before running the PaintProc.
- % There's no harm in doing this for colored patterns,
- % so for simplicity, we always do it.
- q
- null sc1 null SC1
- exch false resolvestream pdfopdict .pdfruncontext
- Q
- DEBUG { (%End PaintProc) = flush } if
- } bdef
-
- /resolvepattern { % <patternstreamdict> resolvepattern <patterndict>
- % Don't do the resolvestream now: just capture the data
- % from the file if necessary.
- dup length dict copy
- dup /FilePosition .knownget {
- 1 index /File get dup fileposition 3 1 roll
- % Stack: dict savepos pos file
- dup 3 -1 roll setfileposition
- dup 3 index /Length get string readstring pop
- % Stack: dict savepos file string
- 3 1 roll exch setfileposition
- 1 index /File 3 -1 roll put
- dup /FilePosition undef
- } if
- dup /PaintProc [
- % Bind the resource dictionary into the PaintProc.
- 2 index /Resources knownoget { oforce } { 0 dict } ifelse
- /.pdfpaintproc cvx
- ] cvx put
- DEBUG {
- (%Pattern: ) print dup === flush
- } if
- } bdef
-
- drawopdict begin
- /g { /DeviceGray cssubst { cs sc1 } { g } ifelse } bdef
- /rg { /DeviceRGB cssubst { cs sc* } { rg } ifelse } bdef
- /k { k } bdef
- /cs { csresolve cs } bdef
- /sc { scresolve { sc* } { sc1 } ifelse } bdef
- /scn /sc load def
- /G { /DeviceGray cssubst { CS SC1 } { G } ifelse } bdef
- /RG { /DeviceRGB cssubst { CS SC* } { RG } ifelse } bdef
- /K { K } bdef
- /CS { csresolve CS } bdef
- /ri { ri } bdef
- /SC { scresolve { SC* } { SC1 } ifelse } bdef
- /SCN /SC load def
- end
-
- % ---------------- Paths ---------------- %
-
- drawopdict begin
- % Path construction
- /m /moveto load def
- /l /lineto load def
- /c /curveto load def
- /v { currentpoint 6 2 roll curveto } def
- /y { 2 copy curveto } def
- /re {
- 4 2 roll moveto exch dup 0 rlineto 0 3 -1 roll rlineto neg 0 rlineto
- closepath
- } def
- /h /closepath load def
- % Path painting and clipping
- /n { n } def
- /S { S } def
- /s { s } def
- /f { f } def
- /f* { f* } def
- /B { B } def
- /b { b } def
- /B* { B* } def
- /b* { b* } def
- /W { W } def
- /W* { W* } def
- /sh { resolveshading shfill } def
- end
-
- % ---------------- XObjects ---------------- %
-
- /xobjectprocs mark % <dict> -proc- -
- /Image { DoImage }
- /Form { DoForm }
- /PS { DoPS }
- .dicttomark readonly def
-
- % Note that the keys in defaultdecodedict are resolved (PostScript, not PDF)
- % color space names.
- /defaultdecodedict mark
- /DeviceGray { pop //01_1 }
- /DeviceRGB { pop //01_3 }
- /DeviceCMYK { pop //01_4 }
- /CIEBasedA { 1 get /RangeA .knownget not { //01_1 } if }
- /CIEBasedABC { 1 get /RangeABC .knownget not { //01_3 } if }
- /Separation { pop //01_1 }
- /DeviceN {
- dup 1 oget length [ exch {0 1} repeat ] readonly
- }
- /Indexed {
- pop [ 0 1 BitsPerComponent bitshift 1 sub ]
- }
- .dicttomark readonly def
-
- /checkaltimage { % <resdict> checkaltimage <resdict[']>
- /UsePrinterImages where {
- pop UsePrinterImages {
- dup /Alternates knownoget {
- {
- dup /DefaultForPrinting knownoget {
- {
- /Image oget exch pop exit
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } forall
- } if
- } if
- } if
- } bdef
-
- /makeimagedict { % <resdict> <newdict> makeimagedict -
- % On return, newdict' is currentdict
- begin
- /Width 2 copy oget def
- /Height 2 copy oget def
- /BitsPerComponent 2 copy oget def
- /Interpolate 2 copy knownoget { def } { pop } ifelse
- makeimagekeys
- } bdef
- /makeimagekeys { % <resdict> makeimagekeys <imagemask>
- % newdict is currentdict
- % Assumes Width, Height, BPC, Interpolate already copied.
- /ImageType 1 def
- /ImageMatrix Width 0 0
- % Handle 0-height images specially.
- Height dup 0 eq { pop 1 } if neg 0 1 index neg
- 6 array astore def
- dup /ImageMask knownoget dup { and } if {
- % Image mask
- % Decode is required for the PostScript image operators.
- /Decode 2 copy knownoget not { //01_1 } if def
- % BitsPerComponent may be missing for masks.
- % The spec requires it, but some producers omit it, and
- % Acrobat Reader doesn't care.
- /BitsPerComponent 2 copy known { pop } { 1 def } ifelse
- true
- } {
- % Opaque image
- dup /ColorSpace oget resolvecolorspace /ColorSpace exch def
- % Decode is required for the PostScript image operators.
- /Decode 2 copy knownoget not {
- ColorSpace //defaultdecodedict
- ColorSpace dup type /arraytype eq { 0 get } if get exec
- } if def
- false
- } ifelse
- % Even though we're going to read data,
- % pass false to resolvestream so that
- % it doesn't try to use Length (which may not be present).
- exch false resolvestream /DataSource exch def
- } bdef
-
- /DoImage {
- checkaltimage dup length 6 add dict makeimagedict doimage
- } bdef
- /doimage { % <imagemask> doimage -
- % imagedict is currentdict, gets popped from dstack
- DataSource exch
- currentdict /Mask knownoget {
- dup type /arraytype eq {
- /ImageType 4 def
- /MaskColor exch def
- } {
- % Mask is a stream, another Image XObject.
- dup length dict makeimagedict
- currentdict end currentdict end
- 4 dict begin
- /ImageType 3 def
- /InterleaveType 3 def
- /MaskDict exch def
- /DataDict exch def
- } ifelse
- } if
- % Stack: datasource imagemask
- { currentdict end setfillcolor imagemask }
- { ColorSpace setcolorspace currentdict end image }
- ifelse
- % Close the input stream, unless it is PDFfile or
- % PDFsource.
- dup dup PDFfile eq exch PDFsource eq or { pop } { closefile } ifelse
- } bdef
-
- /DoForm {
- dup length dict copy
- dup [ /pop load 2 index /Resources knownoget { oforce } { 0 dict } ifelse
- 3 index false /resolvestream cvx
- pdfopdict /.pdfruncontext cvx
- ] cvx /PaintProc exch put
- execform
- } bdef
-
- /DoPS {
- true resolvestream cvx exec
- } bdef
-
- drawopdict begin
- /Do
- { PDFfile fileposition exch
- dup Page /XObject rget not { /undefined cvx signalerror } if
- exch pop dup /Subtype get xobjectprocs exch get
- % Don't leave extra objects on the stack while executing
- % the definition of the form.
- 3 -1 roll 2 .execn
- PDFfile exch setfileposition
- } bdef
- end
-
- % ---------------- In-line images ---------------- %
-
- % Undo the abbreviations in an in-line image dictionary.
- % Note that we must look inside array values.
- % /I is context-dependent.
- /unabbrevkeydict mark
- /BPC /BitsPerComponent /CS /ColorSpace /D /Decode /DP /DecodeParms
- /F /Filter /H /Height /I /Interpolate /IM /ImageMask /W /Width
- .dicttomark readonly def
- /unabbrevvaluedict mark
- /AHx /ASCIIHexDecode /A85 /ASCII85Decode /CC /CalCMYK
- /CCF /CCITTFaxDecode /CG /CalGray /CR /CalRGB
- /DCT /DCTDecode /CMYK /DeviceCMYK /Fl /FlateDecode
- /G /DeviceGray /RGB /DeviceRGB
- /I /Indexed /LZW /LZWDecode /RL /RunLengthDecode
- .dicttomark readonly def
- /unabbrevtypedict mark
- /nametype {
- //unabbrevvaluedict 1 index .knownget { exch pop } if
- }
- /arraytype {
- dup 0 1 2 index length 1 sub {
- 2 copy get unabbrevvalue put dup
- } for pop
- }
- .dicttomark readonly def
- /unabbrevvalue { % <obj> unabbrevvalue <obj'>
- oforce //unabbrevtypedict 1 index type .knownget { exec } if
- } bdef
-
- drawopdict begin
- /BI { mark } bdef
- /ID {
- counttomark 2 idiv dup 6 add dict begin {
- exch //unabbrevkeydict 1 index .knownget { exch pop } if
- exch unabbrevvalue def
- } repeat pop
- /File PDFsource def
- currentdict makeimagekeys doimage
- PDFsource token pop /EI ne { /ID cvx /syntaxerror signalerror } if
- } bdef
- end
-
- % ================================ Text ================================ %
-
- drawopdict begin
- % Text control
- /BT { BT } def
- /ET { ET } def
- /Tc { Tc } def
- /TL { TL } def
- /Tr { Tr } def
- /Ts { Ts } def
- /Tw { Tw } def
- /Tz { Tz } def
- % Text positioning
- /Td { Td } def
- /TD { TD } def
- /Tm { Tm } def
- /T* { T* } def
- % Text painting
- /Tj { Tj } def
- /' { ' } def
- /" { " } def
- /TJ { TJ } def
- end
-
- % ============================== Annotations ============================== %
-
-
-
- % Get and normalize an annotation's rectangle.
- /annotrect { % <annot> annotrect <x> <y> <w> <h>
- /Rect get aload pop
- exch 3 index sub dup 0 lt { dup 5 -1 roll add 4 1 roll neg } if
- exch 2 index sub dup 0 lt { dup 4 -1 roll add 3 1 roll neg } if
- } bdef
-
- % Set an annotation color.
- /annotsetcolor { % <annot> annotsetcolor -
- /C knownoget { setrgbcolor } { 0 setgray } ifelse
- } bdef
-
- % Draw the border. Currently, we ignore requests for beveling, and we
- % don't round the corners of rectangles.
- /strokeborder { % <annot> <width> <dash> strokeborder -
- gsave
- 2 index annotsetcolor
- 0 setdash dup setlinewidth
- exch annotrect
- 2 { 4 index sub 4 1 roll } repeat
- 2 { 4 index 0.5 mul add 4 1 roll } repeat
- rectstroke pop
- grestore
- } bdef
-
- % Draw an annotation border.
- /drawborder { % <annot> drawborder -
- gsave
- dup /BS knownoget {
- dup /W knownoget not { 1 } if
- [] 2 index /S knownoget {
- /D eq { 2 index /D knownoget not { [3] } if exch pop } if
- } if 3 -1 roll pop strokeborder
- } {
- dup /Border knownoget {
- dup 2 get
- exch dup length 3 gt { 3 get } { pop [] } ifelse
- strokeborder
- } {
- pop
- } ifelse
- } ifelse
- grestore
- } bdef
-
- % Draw an annotation.
- /drawannot { % <annot> drawannot -
- gsave
- dup /Subtype get /Widget eq
- 1 index /F knownoget not { 0 } if 2 and 0 eq and {
- dup drawborder
- dup /AP knownoget {
- % Always use the Normal appearance.
- /N oget
- % Acrobat Distiller produces files in which this Form
- % XObject lacks Type and Subtype keys. This is illegal,
- % but Acrobat Reader accepts it. The only way we can
- % tell whether this is a Form or a set of sub-appearances
- % is by testing for the stream Length key.
- dup /Length known not {
- 1 index /AS knownoget not { () } if
- % Stack: annot Ndict AS
- 2 copy knownoget {
- exch pop exch pop
- } {
- % Pick any one.
- pop { exch pop oforce exit } forall
- } ifelse
- } if
- % Acrobat Distiller produces files in which this Form
- % XObject lack FormType and Matrix keys. This is illegal,
- % but Acrobat Reader accepts it. Patch this up now.
- dup /FormType known not {
- dup length 1 add dict copy dup /FormType 1 put
- } if
- dup /Matrix known not {
- dup length 1 add dict copy dup /Matrix matrix put
- } if
- gsave 1 index annotrect pop pop translate
- DoForm
- } if
- } if pop
- grestore
- } bdef
-
- end % pdfdict
- end % GS_PDF_ProcSet
- .setglobal
-